package org.hikari.qqbot.xiuxian.service.impl;

import lombok.RequiredArgsConstructor;
import org.hikari.qqbot.xiuxian.configuration.ApplicationProperties;
import org.hikari.qqbot.xiuxian.service.IUserService;
import org.hikari.qqbot.xiuxian.service.bo.UserSetting;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Objects;

/**
 * created at 2024-12-16 01:21:38
 *
 * @author yinchao
 * @version 1.0
 **/
@RequiredArgsConstructor
@Service
public class ApplicationPropertiesUserService implements IUserService {

    private final ApplicationProperties applicationProperties;

    @Override
    public Collection<? extends UserSetting> allUserSettings() {
        return applicationProperties.getSetting().getUser();
    }

    @Override
    public UserSetting getUserSetting(Long userId) {
        for (UserSetting setting : applicationProperties.getSetting().getUser()) {
            if (Objects.equals(setting.getUserId(), userId)) {
                return setting;
            }
        }
        return null;
    }

}
